<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>消息管理</title>
	<%@ include file="/view/common/tags.jsp"%>
	<script type="text/javascript" src="${sysManagerV1}/js/My97DatePicker/WdatePicker.js"> </script>
</head>
<body>
	<section class="content">
    	<div class="row">
            <div class="col-md-12">
                <div class="box">
                	<div class="box-body">
						<div class="panel panel-default">
                            <div class="panel-body" style="padding-bottom:5px;">
                                <form class="form-horizontal" action="" method="post" id="dataForm">
                                	<div class="searchMenu">
                                	    <div>
                                		    <label>战队：</label>
	                                        <sk:select cssClass="form-control select" name="wm[TEAM_ID]" value="${page.wm.TEAM_ID}" >
	                                            <option  value="">请选择</option>
                                                <c:forEach var="team" items="${teamList}">
    	                                            <option  value="${team.value }">${team.label1}</option>
                                                </c:forEach>
	                                        </sk:select>
                                        </div>
                                        <div>
                                        <label>用户帐号：</label>
                                            <input type="text" class="form-control" name="wm[_LIKE$USER_ACCOUNT]" value="${page.wm._LIKE$USER_ACCOUNT}"  placeholder="请输入用户帐号">
                                        </div>
                                        <div>
                                        <label>提交时间：</label>
                                            <input id="createTimeStart" name="wm[_MORE_EQUAL$APPLY_TIME]" value="${page.wm._MORE_EQUAL$APPLY_TIME}"  type="text"  class="Wdate"
											  onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',startDate:'%y-%M-%d 00:00:00',alwaysUseStartDate:true,maxDate:'#F{$dp.$D(\'createTimeEnd\')}',minDate:'#F{$dp.$D(\'createTimeEnd\',{d:-30,H:-23,m:-59,s:-59})}'})" />
											  <span class="pull-left">&nbsp;-&nbsp;</span>
											  <input id="createTimeEnd" name="wm[_LESS_EQUAL$APPLY_TIME]" value="${page.wm._LESS_EQUAL$APPLY_TIME}"  class="Wdate"
								               onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',startDate:'%y-%M-%d 23:59:59',alwaysUseStartDate:true,minDate:'#F{$dp.$D(\'createTimeStart\')}',maxDate:'#F{$dp.$D(\'createTimeStart\',{d:+30,H:+23,m:+59,s:+59})}'})" />
                                        </div>
	                                    <div class="glType">
                                    	    <label>审核状态：</label>
	                                        <sk:select cssClass="form-control select" name="wm[AUDIT_STATE]" value="${page.wm.AUDIT_STATE}">
	                                            <option  value="">请选择</option>
	                                            <option  value="10">待审核</option>
	                                            <option  value="20">通过</option>
	                                            <option  value="30">拒绝</option>
	                                        </sk:select>
	                                    </div>
                                        <div class="mal10" >
                                            <button type="button"  class="btn btn-primary btn-sm"  onclick="findData()"><span class='glyphicon glyphicon-search'></span>查&nbsp;询</button>
                                        </div>
                                	</div>
                                </form>
                        	</div>
						</div>
                        <table class="table table-hover table-condensed table-bordered table-striped" id="dataTable" >
                            <thead>
                            	<tr>
                                	<th data-field="index" data-align="center" data-formatter="indexFormatter" style="width:100px;">序号</th>
                                	<th data-field="teamName" data-align="center" data-sortable="true">战队名称</th>
                                	<th data-field="userAccount" data-align="center" data-sortable="true">用户帐号</th>
                                	<th data-field="userName" data-align="center" data-sortable="true">用户名称</th>
                                	<th data-field="userIdCard" data-align="center">身份证号</th>
                                	<th data-field="userIdCardImg" data-align="center" data-formatter="userIdCardImgFormatter">身份证图片</th>
                                	<th data-field="applyTime" data-align="center" data-sortable="true">提交时间</th>
                                    <th data-field="auditState" data-align="center" data-sortable="true" data-formatter="auditStateFormatter">审核状态</th>
                                    <th data-field="deleteButton" data-align="center"  data-formatter="buttonFormatter" >操作</th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
       	</div>
	</section>
   <%@ include file="/view/common/footer.jsp"%>
</body>
<script>


// 提示信息
var msgg='<%=request.getAttribute("msg")%>';
if (msgg && msgg!=null && msgg!='null') {
	  layer.msg(msgg);
}

//加载table 数据
$(function(){
    $("#dataTable").bootstrapTable({
        url: "${sysManagerV1}/pubgUserReal/dataList",
        method:"get",
        pagination:true,
        sidePagination:"server",
        queryParams: function(params) {
            return $.extend({}, params, parseJson(decodeURIComponent($("#dataForm").serialize())));
        }
    });
})

//查询
function findData(){
    $("#dataTable").bootstrapTable("refresh", {});
}

/*bootstrap table点击行事件*/
$(function(){
    $("body").on("click","table>tbody>tr",function(){
        $(this).css("background","#e1ecf1").siblings().css("background","");
    });
})

// 图片格式化
function userIdCardImgFormatter(value, row){
	return "<img src='" + value + "' style='width:100px; height:100px;cursor:zoom-in'  onclick='openImage(\"" + value + "\")'/>";
}

//使用bind方法绑定click事件
function openImage(url){
    var infos = "<img src='" + url + "' style='width:100%; height:100%' />";
    layer.open({
        type: 1,
        title: false,
        shadeClose: true, //开启遮罩关闭
        area: ['70%', '60%'],
        content: infos
    });
}

// 审核状态格式化
function auditStateFormatter(value, row){
	var html = "<span class='text-warning'>待审核</span>";
	if(value == 20){
		html = "<span class='text-success'>审核通过</span>";
	} else if(value == 30){
		html = "<span class='text-danger'>审核拒绝</span>";
	}
	return html;
}

//操作按钮
function buttonFormatter(value, row, index) {
    if(row.auditState != '10'){
		return "";
	}
    var caozuo2 = "<button id='btn_edit' type='button' onclick='auditRealName("+row.rowId+", 20," + row.userId+ ");' class='btn btn-default btn-sm'><span class='glyphicon glyphicon-pencil'></span>&nbsp;通&nbsp;过&nbsp;</button>";
    var caozuo3 = "<button id='btn_edit' type='button' onclick='auditRealName("+row.rowId+", 30," + row.userId+ ");' class='btn btn-default btn-sm'><span class='glyphicon glyphicon-remove'></span>&nbsp;拒&nbsp;绝&nbsp;</button>";
    return caozuo2 + caozuo3;
}

// 审核  0：通过     1：拒绝
function auditRealName(rowId,flag,userId){
	var tip = "拒绝";
	if(flag == 0){
		tip = "通过";
	}
	tip = "您确定" + tip + "该队员的实名审核吗？";
	layer.confirm(tip, {btn: ['确认', '取消']},
	 function(){
	     if (rowId == null || rowId == "") {
	         layer.msg("id不能为空!");
	         return;
	     }
	     $.ajax({
	         url: "${sysManagerV1}/pubgUserReal/auditMemberRealName",
	         type: "post",
	         cache: false,
	         data: {rowId:rowId, userId:userId,auditState:flag},
	         dataType:"json",
	         async:false,
	         success: function(data) {
	             if (data.code == 0) {
	                 layer.msg(data.message, {icon: 1});
	                 findData();
	             } else if(data.code == -2){
	                 window.location.href="/";
	             } else {
	                 layer.msg(data.message, {icon: 5});
	             }
	         },
	         error: function(err){
	             alert(JSON.stringify(err));
	         }
	     });
	 });
}

</script>
<style>
    .imgbox:hover{cursor:zoom-in}
</style>
</html>